package com.course.utils.web;

import com.course.model.HttpConfigBean;
import com.course.model.resp.BaseModel;
import com.course.model.resp.ConfigResp;
import com.course.model.resp.NewsVo;
import com.course.model.resp.TestResp;
import com.course.model.resp.UserVo;
import com.course.model.resp.Version;

import java.util.HashMap;

public class HttpManager {

    private static HashMap<Integer, HttpConfigBean> map = new HashMap<>();

    static {
        map.put(HttpAction.test.value, new HttpConfigBean(HttpAction.test.value)
                .buildAction(HttpAction.test.action)
                .buildLoadDialog(true).buildCache(true).buildErrorToast(true).buildClass(TestResp.class));
        map.put(HttpAction.testPage.value, new HttpConfigBean(HttpAction.test.value)
                .buildAction(HttpAction.testPage.action)
                .buildLoadDialog(true).buildCache(true).buildErrorToast(true).buildClass(String.class));
        map.put(HttpAction.configGet.value, new HttpConfigBean(HttpAction.configGet.value)
                .buildAction(HttpAction.configGet.action)
                .buildLoadDialog(true).buildCache(true).buildErrorToast(true).buildClass(ConfigResp.class));
        map.put(HttpAction.imagUpload.value, new HttpConfigBean(HttpAction.imagUpload.value)
                .buildAction(HttpAction.imagUpload.action)
                .buildLoadDialog(true).buildCache(true).buildErrorToast(true).buildClass(String.class));
        map.put(HttpAction.newsQuery.value, new HttpConfigBean(HttpAction.newsQuery.value)
                .buildAction(HttpAction.newsQuery.action)
                .buildLoadDialog(false).buildCache(false).buildErrorToast(false).buildClass(NewsVo.class));
        map.put(HttpAction.loginReg.value, new HttpConfigBean(HttpAction.loginReg.value)
                .buildAction(HttpAction.loginReg.action)
                .buildLoadDialog(false).buildCache(false).buildErrorToast(false).buildClass(UserVo.class));
        map.put(HttpAction.imagUploads.value, new HttpConfigBean(HttpAction.imagUploads.value)
                .buildAction(HttpAction.imagUploads.action)
                .buildLoadDialog(false).buildCache(false).buildErrorToast(false).buildClass(String.class));
        map.put(HttpAction.newVideoUpload.value, new HttpConfigBean(HttpAction.newVideoUpload.value)
                .buildAction(HttpAction.newVideoUpload.action)
                .buildLoadDialog(false).buildCache(false).buildErrorToast(false).buildClass(BaseModel.class));

        map.put(HttpAction.versionGet.value, new HttpConfigBean(HttpAction.versionGet.value)
                .buildAction(HttpAction.versionGet.action)
                .buildLoadDialog(false).buildCache(false).buildErrorToast(false).buildClass(Version.class));


    }

    public static HttpConfigBean getHttpConfig(int val) {
        if (!map.containsKey(val)) {
            return null;
        }
        return map.get(val);
    }


}
